﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using ZR.Admin.WebApi.Filters;
using ZR.ServiceCore.Signalr;

namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 测试接口
    /// </summary>
    [Verify]
    [Route("system/Test")]
    [ApiExplorerSettings(GroupName = "sys")]
    public class TestController : BaseController
    {
        private readonly IHubContext<MessageHub> _hubContext;

        public TestController(IHubContext<MessageHub> hubContext)
        {
            _hubContext = hubContext;
        }

        /// <summary>
        /// 测试发送
        /// </summary>
        /// <returns></returns>
        [HttpGet("send")]
        [AllowAnonymous]
        public IActionResult SendMsg([FromQuery] string msg)
        {
            _hubContext.Clients.All.SendAsync("receiveNotice", msg);
            return ToResponse(true, msg);
        }

        //public IActionResult TriggerEvent()
        //{
        //    CurrentAppInfo.Current.communicationPairs[""].HandInvoke(1, "", "");
        //    return ToResponse(true);
        //}
    }
}